package cn.itcast.date;

import java.util.Calendar;


public class Test02 {
    public static void main(String[] args) {
        //获取日历类对象
        Calendar c = Calendar.getInstance();

        //get方法
        int year = c.get(Calendar.YEAR);
        System.out.println(year);

        int month = c.get(Calendar.MONTH) + 1;
        System.out.println(month);

        int date = c.get(Calendar.DATE);
        System.out.println(date);


        //set方法
        c.set(c.YEAR, 2010);
        year = c.get(Calendar.YEAR);
        System.out.println(year);

        //add方法
        c.add(Calendar.YEAR, 2);
        System.out.println(c.get(Calendar.YEAR));
    }
}
